home *** CD-ROM | disk | FTP | other *** search
- <PUBLIC:COMPONENT lightWeight=true>
- <PUBLIC:METHOD NAME="getDataAsync" />
- <PUBLIC:METHOD NAME="getDataAsyncAlbum" />
- <PUBLIC:METHOD NAME="getDataAsyncAlbumList" />
- <PUBLIC:METHOD NAME="getDataAsyncHeadline" />
- <PUBLIC:METHOD NAME="getDataAsyncHeadlineList" />
- <PUBLIC:METHOD NAME="getNodeText" />
- <PUBLIC:METHOD NAME="getSubNode" />
- <PUBLIC:METHOD NAME="saveIDs" />
- <PUBLIC:METHOD NAME="Stop" />
- <PUBLIC:METHOD NAME="setNoData" />
- <PUBLIC:METHOD NAME="setNoMedia" />
- <PUBLIC:METHOD NAME="buildNoData" />
- <PUBLIC:METHOD NAME="getUrl" />
-
- <PUBLIC:PROPERTY NAME="AID" />
- <PUBLIC:PROPERTY NAME="PID" />
- <PUBLIC:PROPERTY NAME="MSIDAlbum" />
- <PUBLIC:PROPERTY NAME="MSIDPerson" />
-
- <SCRIPT LANGUAGE="JScript">
- var sPID, sAID;
-
- var aDataCache = new Array();
- var aPreCacheList = new Array('info_home', 'info_artistinfo', 'info_albuminfo_bcd', 'info_relatedalbums', 'info_artistbio', 'info_latestreleases', 'info_albumreview', 'info_relatedartists', 'info_relatedradio');
- var sPreCacheKey = '', iPreCacheCurrent = 0;
-
- function getDataAsync2(sPage, sPageForCache, fnCallback, sParam)
- {
- var sTOC = element.document.all('toc').innerText, sContentID = element.document.all('contentid').innerText, sCollectionID, sGenre;
- sCollectionID = element.document.all('collectionid').innerText;
- sGenre = element.document.all('genretext').innerText;
-
- if (sTOC.length || sContentID.length)
- getDataExAsync(sPage, sPageForCache,
- '&toc=' + sTOC + '&content_id=' + sContentID + '&a_id=' + AID + '&p_id=' + PID + '&msid_person=' + MSIDPerson + '&msid_album=' + MSIDAlbum + '&genre=' + sGenre + sParam,
- fnCallback,
- sTOC + ':' + sCollectionID + ':' + sParam);
- else
- {
- var p = element.document.all('player')
- if (!p.currentMedia)
- setNoMedia();
- else
- setToclessMedia();
- }
- }
-
- function getDataAsyncAlbum(sPage, fnCallback, sParam)
- {
- getDataExAsync(sPage, sPage, '&a_id=' + sParam, fnCallback, '');
- }
-
- function getDataAsyncAlbumList(sPage, fnCallback, sParam)
- {
- getDataAsync2(sPage, sPage + sParam, fnCallback, '&type=' + sParam);
- }
-
- function getDataAsyncHeadline(sPage, fnCallback, sParam)
- {
- getDataExAsync(sPage, sPage, '&article_id=' + sParam, fnCallback, sParam);
- }
-
- function getDataAsyncHeadlineList(sPage, fnCallback)
- {
- getDataAsync2(sPage, sPage, fnCallback, '');
- }
-
- function getDataAsync(sPage, fnCallback)
- {
- getDataAsync2(sPage, sPage, fnCallback, '');
- }
-
-
- function saveIDs(oXML)
- {
- var sTemp;
-
- sTemp = getNodeText(oXML, 'a_id');
- if (sTemp.length > 0)
- AID = sTemp;
-
- sTemp = getNodeText(oXML, 'p_id');
- if (sTemp.length > 0)
- PID = sTemp;
-
- sTemp = getNodeText(oXML, 'msid_person');
- if (sTemp.length > 0)
- MSIDPerson = sTemp;
-
- sTemp = getNodeText(oXML, 'msid_album');
- if (sTemp.length > 0)
- MSIDAlbum = sTemp;
-
- }
-
-
- var oXMLCurrent = null, oCurrentData = null, iBadUrl = 0, iNoCallback = 0, fStartPreCache = false;
- function Callback()
- {
- if (oXMLCurrent)
- {
- if (oXMLCurrent.readyState == 4)
- {
- if (oCurrentData && oCurrentData.pfn)
- {
- if (oXMLCurrent.parseError.errorCode != 0)
- setServerError(oXMLCurrent.parseError);
- else
- {
- oCurrentData.pfn(oXMLCurrent);
- addAttribution(oXMLCurrent);
- }
- // if (fStartPreCache)
- // {
- // fStartPreCache = false;
- // window.setTimeout(nextPreCache, 2000);
- // }
- }
- else
- setInternalError();
- }
- }
- }
-
- function addAttribution(oXML)
- {
- var aProviders = oXML.getElementsByTagName('Attribution'), i, oP, oFooter = element.document.all('footer');
- for (i = 0; i < aProviders.length; i++)
- oFooter.addProvider(getNodeText(aProviders[i], 'ProviderName'));
- }
-
- function Stop()
- {
- oCurrentData = null;
- oXMLCurrent = null;
- }
-
- function getXMLUrl(sPage, sParams, sVersion)
- {
- return 'http://windowsmedia.com/redir/servedocument.asp?locale=' + L_CurrentLocale_Text + '&version=' + sVersion + '&doc=' + sPage + sParams;
- }
-
- var sVersion = '';
- function IsDataAccessAllowed()
- {
- var fGetData = false;
- p = element.document.all('player')
- if (p && p.isOnline)
- {
- ex = window.external;
- if (ex)
- {
- if (ex.appColorMedium)
- {
- if (ex.IsAutoMetadataDownloadAllowed())
- fGetData = true;
- else
- setPrivacy()
- }
- else
- fGetData = true;
- }
- if (!p.currentMedia) setNoMedia();
- if (sVersion == '') sVersion = p.versionInfo;
- }
- else
- setOffline();
- return fGetData
- }
-
- var iCacheCount = 0, iNoCache = 0;
- function getDataExAsync(sPage, sPageForCache, sParams, fnCallback, sCacheKey)
- {
- var oXML, oCache, fDoDownload;
-
- Stop();
- if (IsDataAccessAllowed())
- {
- var sUrl = getXMLUrl(sPage, sParams, sVersion);
-
- oCache = aDataCache[sPageForCache];
- fDoDownload = true;
- if (oCache)
- {
- if (!IsVAGUID(MSIDPerson))
- {
- if (sCacheKey.length && (oCache.key == sCacheKey))
- {
- if (oCache.xml)
- {
- oXML = oCache.xml;
- oCache.url = oXML.url;
- fDoDownload = false;
- }
- }
- }
- }
-
- if (fDoDownload)
- {
- iNoCache++;
- oXMLCurrent = getXMLData(sUrl, Callback);
-
- oCache = CreateCacheEntry(sCacheKey, oXMLCurrent, sUrl, fnCallback)
- if (sCacheKey.length)
- aDataCache[sPageForCache] = oCache;
-
- oCurrentData = oCache;
- }
- else
- {
- oCache.pfn = fnCallback;
- oCurrentData = oCache;
- iCacheCount++;
- oXMLCurrent = oXML;
- if (oXML.readyState == 4)
- window.setTimeout(Callback, 0);
- }
- }
- }
-
- var sPreCacheKey = '', iCurrentPreCache = 0, sPreCacheParams;
- function startPreCache(sCacheKey, sParams)
- {
- if (sCacheKey != sPreCacheKey)
- {
- iCurrentPreCache = 0;
- sPreCacheKey = sCacheKey;
- sPreCacheParams = sParams;
- fStartPreCache = true;
- }
- }
-
- function nextPreCache()
- {
- if (iCurrentPreCache < aPreCacheList.length)
- {
- window.status = 'Pre: ' + aPreCacheList[iCurrentPreCache];
- getDataForCache(aPreCacheList[iCurrentPreCache], sPreCacheParams, sPreCacheKey);
- window.setTimeout(nextPreCache, 2000);
- iCurrentPreCache++;
- }
- }
-
- var oCurrentPreCache = null, sCurrentPreCachePage;
- function PreCacheCallback()
- {
- if (oCurrentPreCache)
- {
- var oXML = oCurrentPreCache.xml
- if (oXML && oXML.readyState == 4)
- {
- if (oXML.parseError.errorCode == 0)
- {
- // alert(sCurrentPreCachePage);
-
- aDataCache[sCurrentPreCachePage] = oCurrentPreCache;
- window.setTimeout(nextPreCache, 2000);
- }
- }
- }
- }
-
- function getDataForCache(sPage, sParams, sCacheKey)
- {
- var oXML, oCache, fDoDownload;
-
- Stop();
- if (IsDataAccessAllowed())
- {
- var sUrl = getXMLUrl(sPage, sParams, sVersion);
- oXML = getXMLData(sUrl, PreCacheCallback);
-
- oCurrentPreCache = CreateCacheEntry(sCacheKey, oXML, sUrl, null)
- sCurrentPreCachePage = sPage;
- }
- }
-
- function getXMLData(sUrl, fnCallback)
- {
- var oXML = new ActiveXObject('Microsoft.XMLDOM');
-
- element.innerText = sUrl;
- oXML.async = true;
- oXML.onreadystatechange = fnCallback;
- oXML.load(sUrl);
- // window.open(sUrl, "new");
- return oXML;
- }
-
- function CreateCacheEntry(sKey, oXML, sUrl, pfnCallback)
- {
- var oCache = new Object();
- oCache.key = sKey;
- oCache.xml = oXML;
- oCache.url = sUrl;
- oCache.pfn = pfnCallback;
- return oCache;
- }
-
- function setOffline()
- {
- setNoData(L_Offline_Text, 'images\\album-review.gif', false);
- }
-
- function setPrivacy()
- {
- setNoData(L_NetAccessOff_Text, 'images\\album-review.gif', false);
- }
-
- function setNoMedia()
- {
- setNoData(L_NoMediaSelected_Text, 'images\\album-review.gif', false);
- }
-
- function setToclessMedia()
- {
- if (IsMediaStream())
- setNoMedia();
- else
- setNoData(L_NoDataAvailable_Text, 'images\\album-review.gif', true);
- }
-
- function setServerError(oError)
- {
- setNoData(L_ServerError_Text + '<br><br>' + oError.reason, 'images\\album-review.gif', false);
- }
-
- function setInternalError()
- {
- setNoData(L_ServerError_Text, 'images\\album-review.gif', false);
- }
-
- function buildNoData(sText, sImage, fDoWizard)
- {
- var s = '<table border=0 cellpadding=0 cellspacing=0><tr>';
- s += '<td width=140 valign=top><img border=0 src="' + sImage + '"></td><td width=8></td><td valign=top class=nodata>';
- if (fDoWizard && IsWizardAvailable())
- s += '<A href="X" class=nodata onclick="window.external.EditMetadata(); return false;">' + sText + '</A></td>';
- else
- s += sText + '<td>';
- return s + '</tr></table>';
- }
-
- var sHTML;
- function sendNoData()
- {
- var oP = getCurrentPage();
-
- if (oP && (oP.readyState == 'complete'))
- oP.noData(sHTML);
- }
-
- function setNoData(sText, sImage, fDoWizard)
- {
- sHTML = buildNoData(sText, sImage, fDoWizard);
- window.setTimeout(sendNoData, 1);
- }
-
- function getNodeText(oXML, sNode)
- {
- if (oXML)
- {
- var oObj = oXML.getElementsByTagName(sNode);
- if (oObj.length > 0)
- return oObj[0].text
- }
- return '';
- }
-
- function getSubNode(oXML, sNode)
- {
- var oObj = oXML.getElementsByTagName(sNode);
- return oObj;
- }
-
- var aTokens = new Array();
- aTokens[0] = '';
- aTokens[1] = 'file://';
- aTokens[2] = 'ftp://';
- aTokens[3] = 'http://';
- aTokens[4] = 'https://';
- aTokens[5] = 'http://www.';
- aTokens[6] = 'https://www.';
- aTokens[7] = 'news://';
- aTokens[8] = 'res://';
- aTokens[9] = 'mms://';
-
- function getUrl(o)
- {
- var iToken, sSite, sPath, sPre;
-
- sSite = getNodeText(o, 'Server');
- if (sSite.length)
- {
- iToken = parseInt(getNodeText(o, 'Token'));
- if ((iToken < 0) || (iToken >= aTokens.length))
- iToken = 0;
-
- sPre = getNodeText(o, 'PrePath');
- sSite = getNodeText(o, 'Server');
- sPath = getNodeText(o, 'FilePath');
-
- return aTokens[iToken] + sPre + sSite + sPath;
- }
- else
- return '';
- }
- </SCRIPT>
- </PUBLIC:COMPONENT>
-